24. Exercise: Preference Summary

Exercise Code

In this exercise, you will get to update the summary for the list preference items.

Exercise: T06.08-Exercise-PreferenceSummary

Preference Summary

Now it's your turn to update the summary for preferences that are of any type other than checkbox

SOLUTION:
  • Implement OnSharedPreferenceChangeListener
  • In onCreatePreferences, iterate over the preferences and call setPreferenceSummary for anything not checkbox
  • Override onSharedPreferenceChanged and handle preferences that are not of type checkbox
  • Register and unregister the OnSharedPreferenceChange listener